package com.neuedu.springmvc.convert;

import org.springframework.core.convert.converter.Converter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author 金山
 * 项目：springmvc-learn
 * site: https://blog.fulfill.com.cn
 * 描述
 * @data 2025/3/189:05
 */
public class MyStringToDateConvert implements Converter<String, Date> {
    @Override
    public Date convert(String source) {

        SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-DD HH:mm:ss");
        Date date = null;

        try {
            date = sdf.parse(source);
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }

        return date;
    }
}
